<? 
    session_start();
	require_once ("core/conn.php");
	$db = get_conn();
	check_session();
	
	$id = $_GET['id'];
	if($id != ''){
		$sql = " select * from modulos where id_modulo='".$id."'"; 
		$result = mysql_query($sql);	
		if($result){
			$row = mysql_fetch_array($result);
			 $id_modulo = $row['id_modulo'];
			 $name = $row['name'];
			 $link = $row['link'];
			 $id_category = $row['id_category'];
			 $target = $row['target'];
			 $nivel = $row['nivel'];
			 $top = $row['top'];
			 $foother = $row['foother'];
			 $description = $row['description'];
			 $file = $row['file'];			 
			 
		}else{
			
			error_handling(__FUNCTION__.$sql,mysql_error());
		}
	}
	//get_header();
?>
<html>
<head>
<link href="css/admin_styles.css" rel="stylesheet" type="text/css" />
<script>
function check_modules(obj){
							
			
						
							
		if(obj.name.value ==''){
								
			alert('Please fill the name');
								
			obj.name.focus();
								
			return false;
							
		}
							
		if(obj.link.value ==''){
								
			alert('Please fill the link');
								
			obj.link.focus();
								
			return false;
							
		}
							

							
		if(obj.file.value ==''){
								
			alert('Please fill the file');
								
			obj.file.focus();
								
			return false;
							
		}
	return true;
						
	}
</script>

</head>
<body>

<form name='modulos' method='post' action='/core/modulos.php' onsubmit='return check_modules(this)'>
  <table border='0' width="100%" align="center">
    <tr>
      <td valign="top" ><div align="center">
          <h2>Modulos</h2>
        </div></td>
    </tr>
    <tr>
      <td valign="top" >
            <table width='100%' border='0'>
              <tr>
                <td width="22%" class="etiqueta_form2">Name</td>
                <td  width="78%"><input class="contenido_forma" type='text' name='name' value='<? echo $name;?>' />
                  <input type='hidden' name='id_modulo' value='<? echo $id_modulo;?>' /></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">Link</td>
                <td><input type='text' class="contenido_forma" name='link' value='<? echo $link;?>' /></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">File</td>
                <td><input name='file' type='text' class="contenido_forma" id="file" value='<? echo $file;?>' /></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">Descripci&oacute;n</td>
                <td><textarea name="description" cols="40" rows="4" class="contenido_forma"><? echo $description;?></textarea></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">Target</td>
                <td><input type="text" class="contenido_forma" name="target" value="<? echo $target?>" /></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">Categoria</td>
                <td><? echo dbcombo("id_category","name","menu_categories","id_category",$id_category,"name",$javascript,$extraitems)?></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">Mostrar</td>
                <td><select name="mostrar" class="contenido_forma" id="mostrar">
                    <option value="Y" <? echo getStatus($mostrar,'Y')?>>S</option>
                    <option value="N" <? echo getStatus($mostrar,'N')?>>N</option>
                  </select></td>
              </tr>
              <tr>
                <td class="etiqueta_form2">Nivel</td>
                <td><select name="nivel" class="contenido_forma">
                    <option value="1" <? echo getStatus($nivel,1)?> >1</option>
                    <option value="2" <? echo getStatus($nivel,2)?>>2</option>
                    <option value="3" <? echo getStatus($nivel,3)?>>3</option>
                    <option value="4" <? echo getStatus($nivel,4)?>>4</option>
                    <option value="5" <? echo getStatus($nivel,5)?>>5</option>
                    <option value="6" <? echo getStatus($nivel,6)?>>6</option>
                    <option value="7" <? echo getStatus($nivel,7)?>>7</option>
                    <option value="8" <? echo getStatus($nivel,8)?>>8</option>
                    <option value="9" <? echo getStatus($nivel,9)?>>9</option>
                    <option value="10" <? echo getStatus($nivel,10)?>>10</option>
                    <option value="11" <? echo getStatus($nivel,11)?>>11</option>
                    <option value="12" <? echo getStatus($nivel,12)?>>12</option>
                    <option value="13" <? echo getStatus($nivel,13)?>>13</option>
                    <option value="14" <? echo getStatus($nivel,14)?>>14</option>
                    <option value="15" <? echo getStatus($nivel,15)?>>15</option>
                    <option value="16" <? echo getStatus($nivel,16)?>>16</option>
                    <option value="17" <? echo getStatus($nivel,17)?>>17</option>
                    <option value="18" <? echo getStatus($nivel,18)?>>18</option>
                    <option value="19" <? echo getStatus($nivel,19)?>>19</option>
                    <option value="20" <? echo getStatus($nivel,20)?>>20</option>
                  </select></td>
              </tr>
              <tr>
                <td colspan='2' align='center'><?
					  if ($id != ""){
						echo "<input type='submit' name='Actualizar' value='Update'>";
						echo "&nbsp;&nbsp;<input type='submit' name='Eliminar' value='Delete'>";										
						echo "&nbsp;&nbsp;<input type='submit' name='Cancel' value='Cancel'>";
					  }else{
						echo "<input type='submit' name='Agregar' value='Add'>";
					  }
					?>
                </td>
              </tr>
            </table>
         
          </td>
    </tr>
  </table>
</form>
</body></html>
